<?php
namespace App\Controllers\Order;
use App\Models\OrderComment\OrderComment;
use App\Models\Goods\Goods;
use App\Models\User\User;

/**
*	获取商品评价
*/
class GetOrderCommon extends \App\Libs\Base\BaseAction
{
    protected function beforeRun() {
        parent::beforeRun();
        //$this->needLogin = TRUE;
    }
	
	public function execute(){
		//获取信息
		$gid = $this->request->get('gid');//商品id
		//验证
		if( empty( $gid ) ){
			return \App\Libs\Views\Json::view(1, '商品不存在', Null );
		}
		//获取评论
		$goodsCommon = OrderComment::findAll(array(
			' gid = :gid: ',
			'bind' => array( 'gid'=> $gid )
		));
		if( empty( $goodsCommon ) ){
			return  \App\Libs\Views\Json::view(0, '暂无评论', [] );
		}else{
			$goodsCommon = $goodsCommon->toArray();
		}
		
	}
}
